/**
 * 0977
 *
 * @Author : Ruoyu Wang
 * @DateTime : 2024/8/12 20:45
 */

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

class Solution {
public:
    vector<int> sortedSquares(vector<int> &nums) {
        vector<int> res(nums.size());
        int l = 0, r = nums.size() - 1;
        int k = nums.size() - 1;
        while (l <= r) {
            if (abs(nums[l]) >= abs(nums[r])) {
                res[k--] = nums[l] * nums[l];
                l++;
            } else {
                res[k--] = nums[r] * nums[r];
                r--;
            }
        }
        return res;
    }
};

int main() {

    return 0;
}